package com.quanshu.exchange.ui.gui.message.chat;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.quanshu.exchange.ui.gui.message.chat.expand.VideoCallActivity;
import com.quanshu.exchange.ui.gui.message.chat.expand.VoiceCallActivity;

public class CallReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        //username
        String from = intent.getStringExtra("from");
        //call type
        String type = intent.getStringExtra("type");
        if ("video".equals(type)) {
            //video call
            Intent intent1 = new Intent(context, VideoCallActivity.class);
            intent1.putExtra("username", from);
            intent1.putExtra("isComingCall", true);
            intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent1);
        } else {
            Intent intent1 = new Intent(context, VoiceCallActivity.class);
            intent1.putExtra("username", from);
            intent1.putExtra("isComingCall", true);
            intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent1);
        }
    }

}